package cn.ang.app.tools;

import java.util.List;

@SuppressWarnings("all")
public class Pagelimit<T> {

    public Pagelimit(int pageno,int pageSize, int totalCount) {
        this.setCurrentPage(pageno);
        this.setPageSize(pageSize);
        this.setTotalCount(totalCount);
    }

    /**当前页码*/
    private int currentPage= 1;

    /**总页数*/
    private int totalPageCount= 1;

    /**页面容量*/
    private int pageSize;

    /**数据总数*/
    private int totalCount;

    /**条件值*/
    private Object o;

    private T object;

    public T getObject() {
        return object;
    }

    public void setObject(T object) {
        this.object = object;
    }

    /**数据结果集*/
    private List<T> list;

    public Object getO() {
        return o;
    }

    public void setO(Object o) {
        this.o = o;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        if(currentPage>0){
            this.currentPage = currentPage;
        }
    }

    public int getTotalPageCount() {
        if(this.totalCount % this.pageSize == 0){
            this.totalPageCount = this.totalCount / this.pageSize;
        }else if(this.totalCount % this.pageSize > 0){
            this.totalPageCount = this.totalCount / this.pageSize + 1;
        }else{
            this.totalPageCount = 0;
        }
        return totalPageCount;
    }

    public void setTotalPageCount(int totalPageCount) {
        if(totalPageCount>=0){
            this.totalPageCount = totalPageCount;
        }
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        if(pageSize > 0){
            this.pageSize = pageSize;
        }
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    @Override
    public String toString() {
        return "Pagelimit{" +
                "currentPage=" + currentPage +
                ", totalPageCount=" + totalPageCount +
                ", pageSize=" + pageSize +
                ", totalCount=" + totalCount +
                ", o=" + o +
                ", object=" + object +
                ", list=" + list +
                '}';
    }
}
